package com.martini.satoken01.config;

import com.martini.satoken01.entity.SysMessageBoarder;
import com.martini.satoken01.mapper.system.SysMessageBoarderMapper;
import com.martini.satoken01.mapper.system.SysUserMapper;
import com.martini.satoken01.service.EmailService;
import com.martini.satoken01.service.LoginInfoCacheService;
import com.martini.satoken01.service.MessageQueueService;
import com.martini.satoken01.service.system.DataSourceMessageBoarderServiceImpl;
import com.martini.satoken01.service.system.DataSourceUserServiceImpl;
import com.martini.satoken01.service.system.MessageBoarderService;
import com.martini.satoken01.service.system.UserService;
import org.springframework.boot.SpringBootConfiguration;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.context.annotation.Bean;

/**
 * 系统配置
 *
 * @author martini at 2021/12/18 23:47
 */
@SpringBootConfiguration
public class SystemConfiguration {
    @Bean
    @ConditionalOnMissingBean
    public UserService userService(SysUserMapper sysUserMapper,
                                   LoginInfoCacheService loginInfoCacheService, MessageQueueService messageQueueService) {
        return new DataSourceUserServiceImpl(sysUserMapper, loginInfoCacheService, messageQueueService);
    }

    @Bean
    @ConditionalOnMissingBean
    public MessageBoarderService messageBoarderService(SysMessageBoarderMapper sysMessageBoarderMapper) {
        return new DataSourceMessageBoarderServiceImpl(sysMessageBoarderMapper);
    }
}
